/**
 * Created by dell on 2018/12/11.
 */
var equipmentData = {};	// 用来存储物体集合

var bootstrapTableOption = {
    url: 'getChargingStationList',
    queryParams: function (params) {
        return {
            /*currentPage: params.pageNumber,// 每页要显示的数据条数
             pageSize: params.pageSize,// 每页显示数据的开始行号
             chargingStationID : $("#chargingStationID").val(),
             equipmentType : $("#equipmentType").val()*/
        }
    },
    columns: [
        {title: '序号', formatter: function (){

        }},
        {field: 'chargingStationID', title: '站编号'},
        {field: 'chargingStationName', title: '充电站名称'},
        {field: 'equipmentCount', title: '充电桩数'},
        {field: 'businessId', title: '运营公司'},
        {field: 'address', title: '地址'},
        {field: 'constructStatus', title: '建设状态',formatter: function (value) {
            switch(value){
                case 0:
                    return '<i class="fa fa-circle" style="color: #1BBB9E"></i>已投运';
                    break;
                case 1:
                    return '<i class="fa fa-circle" style="color: #E4AE1E"></i>建设中';
                    break;
                case 2:
                    return '<i class="fa fa-circle" style="color: #929292"></i>规划中';
                    break;
                case 3:
                    return '<i class="fa fa-circle" style="color: #3A3A3A"></i>禁用';
                    break;
                default:
                    return '未知';
            }
        }},
        {field: 'updateDTTM', title: '更新时间', type:"date2String"},
        {
            title: '操作', formatter: function (value, row, index) {
            return ["<a href='javascript:location.reload();' style='color: #0088EA'>刷新</a>"].join('');
        }}

    ],
    responseHandler: function (data) {
        equipmentData = data.list;
        return data;
    }
};

/* 根据查询条件获取充电站信息 */
function search() {
    $('#chargingTable').bootstrapTable('selectPage', 1);
}

$(document).ready(function () {
    /*
     $.ajax({
     url : 'getEquipmentInfo',
     type : 'post',
     dataType : 'json',
     success : function(data) {
     alert(data);
     }
     });*/
    setBootstrapTable('#chargingTable', bootstrapTableOption);

    /* 修改统计信息内容
     $.ajax({
     url: "constructionStateStatistics",
     type: "post",
     dateType: "json",
     success: function (data) {
     $("#state0").html(" 已投运：" + data[0]);
     $("#state1").html(" 建设中：" + data[1]);
     $("#state2").html(" 规划中：" + data[2]);
     $("#state3").html(" 已禁用：" + data[3]);
     }
     });  */
});

function setBootstrapTable(id, bootstrapTableOption) {
    $(id).bootstrapTable(
        $.extend(true,
            {url: undefined,
                queryParamsType: '',
                queryParams: function (params) { return params;},
                dataField: 'list',
                columns: [[]],
                paginationLoop: false,
                striped: true,
                pagination: true,
                sidePagination: 'server',
                pageSize: 10,
                pageList: [5, 10, 25, 50, 100],
                paginationPreText: "上一页",
                paginationNextText: "下一页",
                buttonsClass: 'select'},
            bootstrapTableOption
        )
    );
}

/* 操作 */
function showSave() {
    alert("操作");
}

/* 重置 */
function reset() {
    alert("重置");
}


